package a2022.a20220930;

/**
 * @author lenovo
 * @date 2022/9/30
 */
public class a {
    public static void main(String[] args) {
        setZeroes(new int[][]{
                {0, 1, 2, 0},
                {3, 4, 5, 2},
                {1, 3, 1, 5}
        });
    }

    public static void setZeroes(int[][] matrix) {
        int len = matrix.length;
        int length = matrix[0].length;
        boolean[] zeroeLen = new boolean[len];
        boolean[] zeroeLength = new boolean[length];

        for (int i = 0; i < len; i++) {
            for (int j = 0; j < length; j++) {
                if (matrix[i][j] == 0) {
                    zeroeLen[i] = zeroeLength[j] = true;
                }
            }
        }
        for (int i = 0; i < len; i++) {
            for (int j = 0; j < length; j++) {
                if(zeroeLen[i]||zeroeLength[j]) matrix[i][j]=0;
            }
        }

    }
}
